package com.sdkj.seckill;

import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 姜柏宇
 */
public class Main0508 {
    public static void main(String[] args) {
        //求1-100的素数
        int N = 100;
        //先用false标记，假设标记的每个数都是素数
        boolean []pre = new boolean[N+1];
        for (int i = 2; i <=N ; i++) {
            //如果当前数是素数，那么从当前数i的平方开始，
            // 每次加上i 的数都标记为true
            if(!pre[i]){
                for (int j = i*i; j <=N ; j += i) {
                    pre[j] = true;
                }
            }
        }
        for (int i = 2;i<=N;i++){
            if(!pre[i]){
                System.out.println(i);
            }
        }
    }
    @Test
    public void  p(){
        String a = new String("abc");
        String b = "abc";
        String c = "abc";
        String d = new String("abc");
        System.out.println(a==b);//f
        System.out.println(b==c);//t
        System.out.println(a==d);//f
        System.out.println("---------------------------------");
        //-128~127
        Integer aa = new Integer(127);
        Integer ee = new Integer(127);
        System.out.println(aa==ee);//false

        Integer cc = 127;
        Integer dd = 127;
        int bb = 127;
        System.out.println(aa==bb);//true,自动拆箱
        System.out.println(aa==cc);//false
        System.out.println(cc==dd);//true
        //大于等于128
        Integer ff = 128;
        Integer gg = 128;
        System.out.println(ff==gg);//false
//        Map<K,V> map = new HashMap<>();
    }
}

//双重锁校验的单例模式
class Singleton{
    private static volatile Singleton singleton;
    private Singleton(){

    }
    public static Singleton getInstance(){
        if(singleton==null){
            synchronized (Singleton.class){
                if (singleton==null){
                    singleton = new Singleton();
                }
            }
        }
        return singleton;
    }
}

class Node<K,V> {

}
